package com.example.practice2023.controller;

import com.example.practice2023.pojo.User;
import com.example.practice2023.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * ClassName: UserController
 * Package: com.example.practice2023.controller
 * Description:
 *
 * @Author hyx
 * @Create 2023/7/3 0:17
 * @Version 1.0
 */
@RestController
@RequestMapping("/user")
@Api(value = "用户数据test",tags = "用户数据接口API")
public class UserController {
    @Resource
  private UserService userService;

    @RequestMapping(value = "/insertStaff",method = RequestMethod.POST)
    public Map<String, Object> insertStaff(@RequestBody User user) {
        return userService.insertStaff(user);
    }

    @RequestMapping(value = "/selectByPage",method = RequestMethod.GET)
    public Map<String, Object> selectByPage(int page, int limit, User user) {
//        System.out.println("selectByPage age=" + user.getAge());
//        System.out.println("selectByPage sex=" + user.getSex());
        return userService.selectByPage(page, limit, user);
    }

    @RequestMapping(value = "/updateStaff",method = RequestMethod.POST)
    public Map<String, Object> updateStaff(@RequestBody User user) {
        return userService.updateStaff(user);
    }

    @RequestMapping(value = "/deleteStaff",method = RequestMethod.POST)
    public Map<String, Object> deleteStaff(@RequestParam Integer id) {
        return userService.deleteStaff(id);
    }
}
